package com.free.semantic.model.conceptmodel;

import com.free.semantic.common.RangeObj;
import com.free.semantic.common.RelationItem;
import com.free.semantic.req.RelaItemDef;
import lombok.Data;

import java.util.List;

@Data
public class RelationDefineItemEntity {

    private Long id;

    private Long relationDefineId;

    public RelationDefineItemEntity() {
    }

    public RelationDefineItemEntity(RelaItemDef relaItemDef) {
        List<RangeObj> sourceObjectList = relaItemDef.getSourceObjectList();
        RelationItem relationItem = new RelationItem();
        relationItem.setSourceObjectList(sourceObjectList);
        relationItem.setDestObject(relaItemDef.getDestObject());
        this.relationDefine = relationItem.toString();
    }


    private String relationDefine;

    public RelaItemDef toRelaItemDef() {
        RelationItem relationItem = RelationItem.parseFromStr(relationDefine);
        RelaItemDef relaItemDef = new RelaItemDef(relationItem.getSourceObjectList(), relationItem.getDestObject());
        return relaItemDef;
    }

}